<!DOCTYPE html>
<html>
	<head>
		<title>人事用户管理</title>
		<!-- css -->
		<link href="../css/themes/base/easyui.css" rel="stylesheet" />
		<link href="../css/themes/skin-coolblack.css" rel="stylesheet" />
		<link href="../css/site.css" rel="stylesheet" />
		<link href="../css/fontawesome/css/font-awesome.min.css" rel="stylesheet" />
		<style>
			.over{top:0;left:0;z-index:9999999;width:100%;height:100%;background-color:#f5f5f5;opacity:.5}
			.layout,.over{position:absolute;display:none}
			.layout{top:40%;left:40%;z-index:100000000;width:20%;height:20%;text-align:center}
		</style>

		<script src="../js/utils/jquery.min.js" type="text/javascript"></script>
		<script src="../js/utils/baseUrl.js"></script>
		<script src="../js/easyui/jquery.easyui.min.js" type="text/javascript"></script>
		<script src="../js/easyui/easyui-lang-zh-CN.js" type="text/javascript"></script>
		<script src="../js/easyui/jquery.easyui.plus.js"></script>


		<script src="../js/utils/common.js"></script>
		<script src="../js/utils/jquery.form.js"></script>


	</head>
	<body>
		<div style="padding:4px 5px 0px 5px;">
			<div class="mvctool">
				<input id="txtQuery" type="text" class="searchText" />
				<a id="btnQuery" class="btn btn-default"><span class="fa fa-search"></span>&nbsp;查询</a>
				<a id="btnCreate" class="btn btn-success"><span class="fa fa-plus"></span>&nbsp;创建</a>
				<a id="btnEdit" class="btn btn-warning"><span class="fa fa-pencil"></span>&nbsp;修改</a>
				<a id="btnDetails" class="btn btn-default"><span class="fa fa-list"></span>&nbsp;详细</a>
				<a id="btnDelete" class="btn btn-danger"><span class="fa fa-trash"></span>&nbsp;删除</a>
				<a id="btnReSet" class="btn btn-warning"><span class="fa fa-key"></span>&nbsp;重设密码</a>
				<a id="btnAllot" class="btn btn-default"><span class="fa fa-user-plus"></span>&nbsp;分配角色</a>
			</div>
			<div id="modalwindow" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
			<table>
				<tr>
					<td style="vertical-align: top; width: 210px;padding-top:3px">
						<div id="p" class="easyui-panel" title="组织架构" style="width:205px;padding:10px;">
							<ul id="StructTree" class="easyui-tree" data-options="onClick:function(node){ getSelected();}">
								<li data-options="attributes:{'id':'201710191111344780000d4287a9144'}"><span>xxx分公司</span>
									<ul>
										<li data-options="attributes:{'id':'20171019111210348000003e68cdefd'}"><span>阿斯蒂芬斯蒂芬</span></li>
									</ul>
								</li>
								<li data-options="attributes:{'id':'20171209201657697402205670d1a3c'}"><span>集团</span>
									<ul>
										<li data-options="attributes:{'id':'20171209202837046402244008da752'}"><span>分公司1</span>
											<ul>
												<li data-options="attributes:{'id':'201712092029463554022399bb6abbc'}"><span>总经办</span></li>
												<li data-options="attributes:{'id':'2017120920333044540229f3520c6ab'}"><span>副总经办</span></li>
												<li data-options="attributes:{'id':'2017120920333836140226a93e72aa9'}"><span>财务</span></li>
												<li data-options="attributes:{'id':'2017120920334618240222039b014b5'}"><span>综合</span></li>
												<li data-options="attributes:{'id':'201712092034078524022eb9cc2940c'}"><span>营销</span></li>
											</ul>
										</li>
									</ul>
								</li>
								<li data-options="attributes:{'id':'root'}"><span>xxx总公司</span>
									<ul>
										<li data-options="attributes:{'id':'201710191112271310000b7ec2e74ca'}"><span>轻微的</span></li>
										<li data-options="attributes:{'id':'201712092016199624022d51cfdd45e'}"><span>ceshi</span></li>
										<li data-options="attributes:{'id':'20140724111955028255487bb419149'}"><span>总经办</span></li>
										<li data-options="attributes:{'id':'201404091100077776052ad7a99ee4b'}"><span>业务部</span></li>
										<li data-options="attributes:{'id':'2014072411283315989084648262155'}"><span>行政部</span></li>
										<li data-options="attributes:{'id':'201407241329469779294b628f6652c'}"><span>市场部</span></li>
										<li data-options="attributes:{'id':'201407241329469439294b628f6652c'}"><span>研发部</span></li>
									</ul>
								</li>
							</ul>
						</div>
					</td>
					<td style="width:3px;">&nbsp;</td>
					<td style="padding: 3px">
						<table id="List"></table>
					</td>
				</tr>
			</table>
			<div id="Pager"></div>

		</div>
		<div id="over" class="over"></div>
		<div id="layout" class="layout"><img src="../img/loading.gif" /></div>
		<div id="fullSetContent"></div>



		<script type="text/javascript">
			function getSelected() {
				var node = $('#StructTree').tree('getSelected');
				if (node) {
					//var s = node.text;
					//if (node.attributes) {
					//    s += "," + node.attributes.id;
					//}
					var id = node.attributes.id;
					$("#List").datagrid("load", {
						depId: id
					});
				}
			}

			$(function() {
				$('#List').datagrid({
					url: baseUrl + '/SysUser/GetList?depId=root',
					width: SetGridWidthSub(220),
					methord: 'post',
					height: SetGridHeightSub(46),
					fitColumns: true,
					sortName: 'Id',
					sortOrder: 'desc',
					idField: 'Id',
					pageSize: 15,
					pageList: [15, 20, 30, 40, 50],
					pagination: true,
					striped: true, //奇偶行是否区分
					singleSelect: true, //单选模式
					onLoadSuccess: function(data) {
						console.log("加载成功")
						$(".datagrid-row td div").addClass("exceed");
					},
					onLoadError: function() {
						console.log("加载失败")
					},
					columns: [
						[{
								field: 'Id',
								title: 'ID',
								width: 25,
								hidden: true
							},
							{
								field: 'UserName',
								title: '用户名',
								width: 55
							},
							{
								field: 'TrueName',
								title: '真实名称',
								width: 55
							},
							{
								field: 'DepName',
								title: '部门',
								width: 55
							},
							{
								field: 'PosName',
								title: '职位',
								width: 55
							},
							{
								field: 'MobileNumber',
								title: '手机号码',
								width: 55
							},
							{
								field: 'PhoneNumber',
								hidden: true,
								title: '电话号码',
								width: 55
							},
							{
								field: 'QQ',
								hidden: true,
								title: 'QQ',
								width: 55
							},
							{
								field: 'EmailAddress',
								hidden: true,
								title: 'Email',
								width: 55
							},
							{
								field: 'OtherContact',
								hidden: true,
								title: '其他联系方式',
								width: 55
							},
							{
								field: 'Province',
								hidden: true,
								title: '省份',
								width: 55
							},
							{
								field: 'City',
								hidden: true,
								title: '城市',
								width: 55
							},
							{
								field: 'Village',
								hidden: true,
								title: '地区',
								width: 55
							},
							{
								field: 'Address',
								hidden: true,
								title: '详细地址',
								width: 55
							},
							{
								field: 'State',
								title: '是否启用',
								width: 35,
								align: 'center',
								formatter: function(value) {
									return EnableFormatter(value)
								}
							},
							{
								field: 'CreateTime',
								title: '创建时间',
								width: 75
							},
							{
								field: 'CreatePerson',
								title: '创建人',
								width: 55
							},
							{
								field: 'RoleName',
								title: '拥有角色',
								width: 255
							}
						]
					]
				});
			});



			//ifram 返回
			function frameReturnByClose() {
				$("#modalwindow").window('close');
			}

			function frameReturnByReload(flag) {
				if (flag)
					$("#List").datagrid('load');
				else
					$("#List").datagrid('reload');
			}

			function frameReturnByMes(mes) {
				$.messageBox5s(Lang.Tip, mes);
			}
			$(function() {
				$("#btnReSet").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {

						var SelId = row.Id;
						$.messager.prompt('初始化密码', row.TrueName + '的密码:', function(r) {
							if (r == "" || r.length < 6) {
								$.messageBox5s(Lang.Tip, '请输入一个5位以上的密码');
							} else {
								$.post("/SysUser/ReSet", {
									Id: SelId,
									Pwd: r
								}, function(data) {
									if (data.type == 1) {
										$.messageBox5s(Lang.Tip, data.message);
									} else {
										$.messageBox5s(Lang.Tip, data.message);
									}
								}, "json");
							}
						});
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$("#btnCreate").click(function() {
					window.parent.addTab("创建", "/SysUser/Create", "fa fa-plus");
				});
				$("#btnEdit").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {
						window.parent.addTab("编辑" + row.TrueName + "的基本信息", "/SysUser/Edit?id=" + row.Id + "&Iedate=" + GetGuid() +
							"", "fa fa-pencil");
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$("#btnDetails").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {
						$("#modalwindow").html(
							"<iframe width='100%' height='100%' scrolling='auto' frameborder='0' src='/SysUser/Details?id=" + row.Id +
							"&Iedate=" + GetGuid() + "'></iframe>");
						$("#modalwindow").window({
							title: '详细',
							width: 720,
							height: 400,
							iconCls: 'fa fa-list'
						}).window('open');
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$("#btnQuery").click(function() {
					var queryStr = $("#txtQuery").val();
					if (queryStr == null) {
						queryStr = "%";
					}
					$("#List").datagrid("load", {
						depId: 'root',
						queryStr: queryStr
					});
				});
				$("#btnDelete").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {
						$.messager.confirm(index_lang_tip, '你要删除所选择的记录吗？', function(r) {
							if (r) {
								$.post("/SysUser/Delete?id=" + row.Id, function(data) {
									if (data.type == 1)
										$("#List").datagrid('load');
									$.messageBox5s(Lang.Tip, data.message);
								}, "json");

							}
						});
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$("#btnAllot").click(function() {
					var row = $('#List').datagrid('getSelected');
					if (row != null) {

						$("#modalwindow").html(
							"<iframe width='100%'  height='100%' scrolling='auto' frameborder='0' src='/SysUser/GetRoleByUser?userId=" +
							row.Id + "&Iedate=" + GetGuid() + "'></iframe>");
						$("#modalwindow").window({
							title: '分配角色',
							width: 720,
							height: 400,
							iconCls: 'fa fa-pencil'
						}).window('open');
					} else {
						$.messageBox5s(Lang.Tip, '请选择要操作的记录');
					}
				});
				$(window).resize(function() {
					$('#List').datagrid('resize', {

					}).datagrid('resize', {
						width: SetGridWidthSub(220),
						height: SetGridHeightSub(46)
					});
				});
			});

			$(function() {
				if (isExitsFunction(window.parent.fullSetButtonOut)) {
					$("#fullSetContent").html(window.parent.fullSetButtonOut());
					$("#fullSetButton").click(function() {
						if ($(this).attr("class") == "fa fa-expand") {
							$(this).removeClass("fa-expand").addClass("fa-compress");
						} else {
							$(this).removeClass("fa-compress").addClass("fa-expand");
						}
						window.parent.fullSet();
					});
				}
			});
		</script>
	</body>
</html>
